package com.lemonPiggy.message.service.impl;

import java.util.List;

import com.lemonPiggy.message.domain.MessageAnnouncementSend;
import com.lemonPiggy.message.mapper.MessageAnnouncementSendMapper;
import com.lemonPiggy.message.model.AnnouncementSendModel;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.IdUtils;
import com.lemonPiggy.message.service.IMessageAnnouncementSendService;
import com.ruoyi.common.core.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 用户通告阅读标记Service业务层处理
 *
 * @author ruoyi
 * @date 2021-08-17
 */
@Service
public class MessageAnnouncementSendServiceImpl implements IMessageAnnouncementSendService {
    @Autowired
    private MessageAnnouncementSendMapper messageAnnouncementSendMapper;

    /**
     * 查询用户通告阅读标记
     *
     * @param id 用户通告阅读标记ID
     * @return 用户通告阅读标记
     */
    @Override
    public MessageAnnouncementSend selectMessageAnnouncementSendById(String id) {
        return messageAnnouncementSendMapper.selectMessageAnnouncementSendById(id);
    }

    /**
     * 查询用户通告阅读标记列表
     *
     * @param messageAnnouncementSend 用户通告阅读标记
     * @return 用户通告阅读标记
     */
    @Override
    public List<MessageAnnouncementSend> selectMessageAnnouncementSendList(MessageAnnouncementSend messageAnnouncementSend) {
        return messageAnnouncementSendMapper.selectMessageAnnouncementSendList(messageAnnouncementSend);
    }

    /**
     * 新增用户通告阅读标记
     *
     * @param messageAnnouncementSend 用户通告阅读标记
     * @return 结果
     */
    @Override
    public int insertMessageAnnouncementSend(MessageAnnouncementSend messageAnnouncementSend) {
        messageAnnouncementSend.setId(IdUtils.simpleUUID());
        messageAnnouncementSend.setCreateTime(DateUtils.getNowDate());
        return messageAnnouncementSendMapper.insertMessageAnnouncementSend(messageAnnouncementSend);
    }

    /**
     * 修改用户通告阅读标记
     *
     * @param messageAnnouncementSend 用户通告阅读标记
     * @return 结果
     */
    @Override
    public int updateMessageAnnouncementSend(MessageAnnouncementSend messageAnnouncementSend) {
        messageAnnouncementSend.setUpdateTime(DateUtils.getNowDate());
        return messageAnnouncementSendMapper.updateMessageAnnouncementSend(messageAnnouncementSend);
    }

    /**
     * 批量删除用户通告阅读标记
     *
     * @param ids 需要删除的用户通告阅读标记ID
     * @return 结果
     */
    @Override
    public int deleteMessageAnnouncementSendByIds(String[] ids) {
        return messageAnnouncementSendMapper.deleteMessageAnnouncementSendByIds(ids);
    }

    /**
     * 删除用户通告阅读标记信息
     *
     * @param id 用户通告阅读标记ID
     * @return 结果
     */
    @Override
    public int deleteMessageAnnouncementSendById(String id) {
        return messageAnnouncementSendMapper.deleteMessageAnnouncementSendById(id);
    }

    /**
     *  通过id查询
     * @param userId
     * @return
     */
    @Override
    public List<String> queryByUserId(String userId) {
        return messageAnnouncementSendMapper.queryByUserId(userId);
    }

    /**
     * 获取我的信息
     * @param announcementSendModel
     * @return
     */
    @Override
    public List<AnnouncementSendModel> getMyAnnouncementSendPage(AnnouncementSendModel announcementSendModel) {
        return messageAnnouncementSendMapper.getMyAnnouncementSendList(announcementSendModel);
    }

    /**
     * 更新用户系统消息阅读状态
     * @param messageAnnouncementSend
     * @return
     */
    @Override
    public int updateMessageSend(MessageAnnouncementSend messageAnnouncementSend,String anntId) {

        return messageAnnouncementSendMapper.updateMessageSend(messageAnnouncementSend,anntId,SecurityUtils.getUserId());
    }


    /**
     * 一键已读
     * @param messageAnnouncementSend
     * @return
     */
    @Override
    public int updateRead(MessageAnnouncementSend messageAnnouncementSend,Long userId) {
        return messageAnnouncementSendMapper.updateRead(messageAnnouncementSend,userId);
    }


}
